<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>两数运算</title>
</head>

<body>
    <input type="text" id="numA" placeholder="请输入第一个数">
    <input type="text" id="numB" placeholder="请输入第二个数">
    <button onclick="calculate()">计算</button>
    <div id="calcResult"></div>
    <script>
        function calculate() {
            var numA = parseFloat(document.getElementById('numA').value);
            var numB = parseFloat(document.getElementById('numB').value);
            var resultDiv = document.getElementById('calcResult');
            var add = numA + numB;
            var subtract = numA - numB;
            var multiply = numA * numB;
            var divide = numB === 0? "除数不能为 0" : numA / numB;
            resultDiv.innerHTML = "加法结果: " + add + "<br>减法结果: " + subtract + "<br>乘法结果: " + multiply + "<br>除法结果: " + divide;
        }
    </script>
</body>

</html>